# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=python-guessit
pkgver=3.7.1
pkgrel=2
pkgdesc='A Python module that extracts as much information as possible from a video filename'
arch=('any')
url='https://github.com/guessit-io/guessit'
license=('LGPL3')
depends=(
  'python'
  'python-dateutil'
  'python-babelfish'
  'python-rebulk'
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-wheel'
  'python-setuptools'
)
checkdepends=('python-pytest' 'python-pytest-mock' 'python-pyyaml')
_commit='54acf7852a157db0f4842206c41db3cc6d36823b'
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

build() {
  cd "$pkgname"

  python -m build --wheel --no-isolation
}

check() {
  cd "$pkgname"

  PYTHONPATH="$PWD:$PYTHONPATH" pytest
}

package() {
  cd "$pkgname"

  python -m installer --destdir="$pkgdir" dist/*.whl

  # delete tests from package
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  rm -rf "$pkgdir$site_packages/guessit/test"
}
